package cn.scu.ne04jdemo.controller;

import cn.scu.ne04jdemo.entitiy.TreeNode;
import cn.scu.ne04jdemo.service.TreeNodeService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TreeNodeController {
    private final TreeNodeService treeNodeService;

    public TreeNodeController(TreeNodeService treeNodeService) {
        this.treeNodeService = treeNodeService;
    }

    @GetMapping("/treeNodes/{hashValue}")
    public ResponseEntity<TreeNode> getTreeNodeByHash(@PathVariable String hashValue) {
        TreeNode node = treeNodeService.getTreeNodeByHash(hashValue);
        return ResponseEntity.ok(node);
    }
}
